<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <link rel="stylesheet" href="aad/css/base.css">
    <link rel="stylesheet" href="aad/css/addBankCard.css">
    <link rel="stylesheet" href="aad/css/mobileSelect.css">
</head>
<body>
  <div class="verification padding">
    <i>验证码</i>
    <input type="text" class="verificationNum" placeholder="请输入短信验证码" onkeyup="this.value=this.value.replace(/[^\d]/g,'');" >
    <span class="phoneVeation">60s</span>
  </div>
  <div  class="submits" @click="submits"><span >支付</span></div>
</body>
<script src="../js/jquery-2.2.3.min.js"></script>
<script src="../js/common.js"></script>
<script src="../js/rem.js"></script>
<script src="shopcar/js/vue.min.js"></script>
<script src="../js/vue-resource.min.js"></script>

<script>
      var disabled = false;
      var time=parseInt($(".phoneVeation").text());
      setTime=setInterval(function(){
          if(time<=0){
              disabled = true
              clearInterval(setTime);
              $('.phoneVeation').html("发送验证码")
              console.log(disabled)
              return;
          }
          time--;
          $(".phoneVeation").text(time + 's');
      },1000);


        $('.phoneVeation').click(function () {
            if(disabled){
                $.ajax({
              url:SURL+'/jfd/shopOrders/paysmsagree',
              type:'post',
              data:{
                  orderunique: localStorage.getItem('orderunique'),
                  payType: "3",
                  bankCardId: localStorage.getItem('bankCardId'),
                  thpinfo:localStorage.getItem('data')
              },
              dataType:'json',
              success:res=>{
                  if(res.code == 0){
                      $('.phoneVeation').html("60s")
                      var time=parseInt($(".phoneVeation").text());
                      setTime1=setInterval(function(){
                          if(time<=0){
                              disabled = true
                              clearInterval(setTime1);
                              $('.phoneVeation').html("发送验证码")
                              return;
                          }
                          time--;
                          $(".phoneVeation").text(time + 's');
                      },1000)
                  }else{
                      alert(res.msg);
                  }

              },error:res=>{
                  alert(res.msg);
              }
          })
            }

      })

      $('.submits').click(function () {

            if($('.verificationNum').val()){

                $.ajax({
                    url:SURL+'/jfd/shopOrders/payagreeconfirm ',
                    type:'post',
                    data:{
                        orderunique: localStorage.getItem('orderunique'),
                        payType: "3",
                        bankCardId: localStorage.getItem('bankCardId'),
                        userId: '1219',
                        smscode:$('.verificationNum').val(),
                        thpinfo:localStorage.getItem('data')
                    },
                    dataType:'json',
                    success:res=>{
                        console.log(res);
                        if(res.code == 0){
                            location.href = 'personal/myorder.html?ling=2'
                        }else{
                            alert(res.msg);
                        }

                    },error:res=>{
                        alert(res.msg);
                    }
                })
            }else {
                alert('请输入验证码')
            }

          // this.$http.post(SURL + '/jfd/shopOrders/thirdPayApply',obj , {emulateJSON: true}).then(res => {
          //     console.log(res);
          // })



      })
</script>
</html>